class MackBook {
  cost() {
    return 9999
  }
}

// 装饰
function Memory(mackbook) {
  // console.log(mackbook.cost);
  let v = mackbook.cost()
  mackbook.cost = () => {
    return v + 1200
  }
}

function Engraving(mackbook) {
  let v = mackbook.cost()
  mackbook.cost = () => {
    return v + 1000
  }
}

function Insurance(mackbook) {
  let v = mackbook.cost()
  mackbook.cost = () => {
    return v + 666
  }
}

let mb = new MackBook() // 丐版

// 加内存
Memory(mb)
Engraving(mb)
Insurance(mb)
console.log(mb.cost());